/**
 * 检查equipment_base表结构的脚本
 */

const mysql = require('mysql2/promise');

// 数据库连接配置
const dbConfig = {
    host: '43.143.253.188',
    port: 3306,
    user: 'nextjs',
    password: 'yEAiRE2jcxTyRBy5',
    database: 'nextjs',
    charset: 'utf8mb4'
};

async function checkTableStructure() {
    let connection = null;
    
    try {
        connection = await mysql.createConnection(dbConfig);
        console.log('✅ 数据库连接成功');

        // 查看表结构
        console.log('📋 equipment_base表结构:');
        const [columns] = await connection.execute('DESCRIBE equipment_base');
        columns.forEach(col => {
            console.log(`   ${col.Field}: ${col.Type} ${col.Null === 'NO' ? 'NOT NULL' : 'NULL'} ${col.Key ? col.Key : ''} ${col.Default ? `DEFAULT ${col.Default}` : ''}`);
        });

        // 查看前几条数据
        console.log('\n📊 equipment_base表前10条数据:');
        const [rows] = await connection.execute('SELECT * FROM equipment_base LIMIT 10');
        console.table(rows);

    } catch (error) {
        console.error('❌ 检查失败:', error.message);
    } finally {
        if (connection) {
            await connection.end();
        }
    }
}

checkTableStructure();
